from typing import List

class Solution:
    # 排序 + 二分查找
    def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
        nums2.sort()  # O(n2 log n2)
        res = set()
        for n1 in nums1:  # O(n1 log n2)
            l = 0
            r = len(nums2) - 1
            while l <= r:
                mid = (l + r) // 2
                if nums2[mid] == n1:
                    res.add(n1)
                    break
                elif nums2[mid] < n1:
                    l = mid + 1
                else:
                    r = mid - 1
        return list(res)
